<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="content-type" content="text/html; charset=utf-8" />
	<script type="text/javascript">
            var aJaxURL		= "server-side/documents/overhead.action.php";		//server side folder url
            var seoyURL		= "server-side/seoy/seoy.action.php";				//server side folder url
            var wsdlURL		= "server-side/wsdl/wsdl.action.php";				//server side folder url
            var fName		= "add-edit-form";									//form name
            var tbName		= "tabs";											//tabs name
            var o_type		= 1;												//Overhead Type start value
            var parent_id	= 0;												//Main Overhead ID if sub Overhead
            var req			= "";
            
            $(document).ready(function() {
                req = getRequest();
                ClearDB();
                GetTabs(tbName);
                //GetOut();
				GetIN();
				//GetOut1();
				//GetIN1();
            });
            
            $(document).on("tabsactivate", "#tabs", function() {
            	var type = GetSelectedTab(tbName);
            	if (type == 0) {
            		GetIN();
            	}else if (type == 1){
            		GetIN1();
                }else if (type == 2){
					GetOut();
                }else if (type == 3){
					GetOut1();
                }
	        });
            
            //SeoYyy
            $(document.body).click(function(e) {
                $("#goods_name").autocomplete("close");
                $("#goods_local_name").autocomplete("close");
                $("#driver_name").autocomplete("close");
                $("#buyer_i_number").autocomplete("close");
                $("#buyer_name").autocomplete("close");
            });
            
            function GetOut() {
                LoadTable("out-overhead");
                GetButtons("add_button_out", "delete_button_out", "export_button_out", "cancel_button_out");
                SetEvents("add_button_out", "delete_button_out", "check-all-out", "out-overhead", fName, aJaxURL);
                $("#cancel_button_out").button("disable");
            }

            function GetOut1() {
                LoadTable("out-overhead1");
                GetButtons("add_button_out1", "delete_button_out1", "export_button_out1", "cancel_button_out1");
                SetEvents("add_button_out", "delete_button_out", "check-all-out", "out-overhead1", fName, aJaxURL);
                $("#cancel_button_out1").button("disable");
            }
            
            function GetIN() {
                LoadTable("in-overhead");
                GetButtons("add_button_in", "delete_button_in", "export_button_in", "cancel_button_in");
                SetEvents("add_button_in", "delete_button_in", "check-all-in", "in-overhead", fName, aJaxURL);
                $("#add_button_in").button("disable");
                $("#cancel_button_in").button("disable");
            } 

            function GetIN1() {
                LoadTable("in-overhead1");
                GetButtons("add_button_in1", "delete_button_in1", "export_button_in1", "cancel_button_in1");
                SetEvents("add_button_in", "delete_button_in", "check-all-in", "in-overhead1", fName, aJaxURL);
                $("#add_button_in1").button("disable");
                $("#cancel_button_in1").button("disable");
            }
            
            function LoadTable(tName) {
                
            	
            	
                if (tName == "out-overhead") {
                    /* Table ID, aJaxURL, Action, Colum Number, Custom Request, Hidden Colum, Menu Array */
                    GetDataTable(tName, aJaxURL, "get_list", 6, "type=" + 0, 0, "", 0, "desc");
                }else if (tName == "out-overhead1") {
                        /* Table ID, aJaxURL, Action, Colum Number, Custom Request, Hidden Colum, Menu Array */
                        GetDataTable(tName, aJaxURL, "get_list", 6, "type=" + 0, 0, "", 0, "desc");
                } else if (tName == "in-overhead") {
                    	 //მისაღები
	                	if (empty(req.overhead_id)){
		                    /* Table ID, aJaxURL, Action, Colum Number, Custom Request, Hidden Colum, Menu Array */
		                    GetDataTable(tName, aJaxURL, "get_list", 6, "type=" + 1 + "&confirm=" + 1, 0, "", 0, "desc");
	                	}else{
		                    var recursive = req.overhead_id;
		                    /* Table ID, aJaxURL, Action, Colum Number, Custom Request, Hidden Colum, Menu Array */
		                    GetDataTable(tName, aJaxURL, "get_list", 6, "type=" + 1 + "&o_id=" + recursive + "&confirm=" + 1, 0, "", 0, "desc");
	                    }
                }else if(tName == "in-overhead1"){ // მიღებული
                     	if (empty(req.overhead_id)){
 		                    /* Table ID, aJaxURL, Action, Colum Number, Custom Request, Hidden Colum, Menu Array */
 		                    GetDataTable(tName, aJaxURL, "get_list", 6, "type=" + 1  + "&confirm=" + 2, 0, "", 0, "desc");
 	                	}else{
		                    var recursive = req.overhead_id;
		                    /* Table ID, aJaxURL, Action, Colum Number, Custom Request, Hidden Colum, Menu Array */
		                    GetDataTable(tName, aJaxURL, "get_list", 6, "type=" + 1 + "&o_id=" + recursive  + "&confirm=" + 2, 0, "", 0, "desc");
 	                    }                       
                } else {
                    var url = GetAjaxURL();
                    var menuLength = [[10], [10]];
                    var id = $("#overhead_id").val();
                    var local_id = $("#local_overhead_id").val();
                    var type = GetSelectedTab(tbName);
                    
                    if (!empty(id))
                        var local_id = id;
                    
                    if (type == 2 || type == 3) { //OUT
                        if (o_type != 6) {
                            /* Table ID, aJaxURL, Action, Colum Number, Custom Request, Hidden Colum, Menu Array  */
                            GetDataTable("goods_list", url, "get_list", 8, "local_id=" + local_id, 0, menuLength, 1, "asc");
                        } else {
                            /* Table ID, aJaxURL, Action, Colum Number, Custom Request, Hidden Colum, Menu Array */
                            GetDataTable("goods_list", url, "get_sub_list", 9, "local_id=" + local_id, 0, menuLength, 1, "asc");
                        }
                    } else if(type == 0 || type == 1) {	//IN
                        /* Table ID, aJaxURL, Action, Colum Number, Custom Request, Hidden Colum, Menu Array */
                        GetDataTable("goods_list", url, "get_list", 7, "local_id=" + local_id, 0, menuLength, 1, "asc");
                    }
                }
            }
            
            function DatatableEnd(tname) {
                if (tname == "goods_list") {
                    
                    var type = GetSelectedTab(tbName);
                    
                    if (type == 0 || type == 1) { //IN
	                    $("#goods_list tr td:eq(3)").filter(function() {
		                    if($(this).text() == search)
		                    	$("#tabs").tabs( "option", "active", 1 );
	                        return $(this).text() == "";
	                    }).parent("tr").css({"color" : "#FF1814", "font-weight" : "bold"});                        
                    }
                    
                    $("#goods_list").css("width", "100%");			//Temporary Solution
                    var id = $("#overhead_id").val();
                    if (!empty(id)) {
                        $("#" + tname + " INPUT[type='checkbox']").attr("disabled", "disabled");
                    }
                }else if(tname == "out-overhead"){
                	$("#out-overhead").css("width", "100%");		//Temporary Solution
                }else if(tname == "in-overhead"){
                	$("#in-overhead").css("width", "100%");			//Temporary Solution
                	
                    if (!empty(req.overhead_id)){
	                    var search = req.overhead_id;
                    	
	                    $("#in-overhead tr td:first-child").filter(function() {
		                    if($(this).text() == search)
		                    	$("#tabs").tabs( "option", "active", 1 );
	                        return $(this).text() == search;
	                    }).parent("tr").dblclick();
                    }
                }
            }
            
            function LoadDialog(form) {
                o_type = $("#o_type").val();												//Overhead Type current value			
                
                $("#sub_overhead_button").css("display", "none");
                
                if (form == fName && o_type == 6) { //Type sub_overhead
                    form = "sub_overhead";
                }
                
                var payed = $("#payed").val();
                if(empty(payed)){
                	$("#payed").val(0);
				}
                
                var type = GetSelectedTab(tbName);
                
                if (type == 2 || type == 3) { //OUT
                    if (form == fName) {  //Main Overhead Page
                        ClearDB();
                       // $("#object").removeAttr("disabled");  //Clear Object selector
                        var buttons = {
                            "save": {
                                text: "შენახვა",
                                id: "save-overhead",
                                click: function() {
                                }
                            },
                            "active": {
                                text: "RS.GE - ზე გააქტიურება",
                                id: "active-overhead",
                                click: function() {
                                }
                            }
                        };
                        /* Dialog Form Selector Name, Buttons Array */
                        GetDialog(fName, 950, "auto", buttons, "");
                        GetButtons("add_button_goods", "delete_button_goods", "export_button_goods");
                        
                        var id		= $("#overhead_id").val();
                        var status	= $("#overhead_status").val();
                        
                        SeoY("driver_id", seoyURL, "overhead_driver_tin", "", 1);
                        SeoY("driver_name", seoyURL, "overhead_driver_name", "", 0);
                        
                        if (!empty(id)) {
                            if (o_type == 4 && status != 0 && status != 2) { //4 Distribution Type and status 0 as save, status 2 as finish
                                $("#sub_overhead_button").css("display", "inline-block");
                                $("#sub_overhead_button").button({
                                    icons: {
                                        primary: "ui-icon-circle-plus"
                                    }
                                });
                            }
                            
                            if (o_type != 3) {
                                var buttons = {
                                    "save": {
                                        text: "RS.GE - ზე გააქტიურება",
                                        id: "active-overhead",
                                        click: function() {
                                        }
                                    }
                                };
                                
                                $("#" + fName).dialog("option", "buttons", buttons);
                                $("#active-overhead").focus();
                            }
                            
                            if (status == 0) {
                                var buttons = {
                                    "save": {
                                        text: "RS.GE - ზე გააქტიურება",
                                        id: "active-saved-overhead",
                                        click: function() {
                                        }
                                    }
                                };
                                
                                $("#" + fName).dialog("option", "buttons", buttons);
                                $("#active-saved-overhead").focus();
                            } else if (status == 1) {
                                var buttons = {
                                    "save": {
                                        text: "RS.GE - ზე დასრულება",
                                        id: "finish-overhead",
                                        click: function() {
                                        }
                                    }
                                };
                                
                                $("#" + fName).dialog("option", "buttons", buttons);
                                $("#active-saved-overhead").focus();
                            } else if (status == 2) {
                                var buttons = {};
                                
                                $("#" + fName).dialog("option", "buttons", buttons);
                                $("#export_button_goods").focus();
                            }
                            
                            DisableHeader();
                            DisableTransport();
                            DisableGoods();
                            
                            $("#local_overhead_id").val(id);
                            LoadTable("goods_list");
                        } else {
                            var local_id	= GetLocalID();
                            var url			= GetAjaxURL();
                            
                            $("#local_overhead_id").val(local_id);
                            
                            LoadTable("goods_list");
                            SetEvents("add_button_goods", "delete_button_goods", "check-all-goods", "goods_list", "add-edit-goods-form", url);
                        }
                    } else if (form == "sub_overhead") {  //Sub Overhead Page
                        ClearDB();
                        var buttons = {
                            "save": {
                                text: "მთავარი ზედნადები",
                                id: "main-overhead",
                                click: function() {
                                }
                            },
                            "active": {
                                text: "ქვე-ზედნადების დასრულება",
                                id: "active-overhead",
                                click: function() {
                                }
                            }
                        };
                        
                        /* Dialog Form Selector Name, Buttons Array */
                        GetDialog(fName, 950, "auto", buttons, "");
                        GetButtons("", "", "export_button_goods");
                        
                        SeoY("buyer_i_number", seoyURL, "overhead_buyer_tin", "", 1);
                        SeoY("buyer_name", seoyURL, "overhead_buyer_name", "", 0);
                                                
                        var id		= $("#overhead_id").val();
                        var status	= $("#overhead_status").val();
                        
                        $("#add_button_goods").css("display", "none");
                        $("#delete_button_goods").css("display", "none");
                        //$(".object").css("display", "none");
                        
                        if (!empty(id)) {
                            if (status == 1 || status == 2) { //???
                                var buttons = {
                                    "save": {
                                        text: "მთავარი ზედნადები",
                                        id: "main-overhead",
                                        click: function() {
                                        }
                                    }
                                };

                                $("#" + fName).dialog("option", "buttons", buttons);
                                $("#main-overhead").focus();
                            }
                            
                            DisableHeader();
                            DisableRelations();
                            
                            $("#local_overhead_id").val(id);
                            $("#active-overhead").focus();
                            
                            LoadTable("goods_list");
                        } else {
                            var local_id = GetLocalID();
                            $("#local_overhead_id").val(local_id);
                            
                            if (empty(parent_id))
                                parent_id = GetParentID(id);
                            
                            AddSubGoods(local_id, parent_id);
                            SetCurrentObject(parent_id);
                        }
                    } else {  //Goods Page
                    	//$("#object").attr("disabled", "disabled");  //Disable Object Selector
                    	var object	= $("#object").val();
                        var id		= $("#goods_id").val();
                    	
                        SeoY("goods_code", seoyURL, "overhead_goods_code", "obj_id=" + object, 1);
                        SeoY("goods_name", seoyURL, "overhead_goods_name", "obj_id=" + object, 0);
                        
                        if (id != "") {
                            DisableGoodsList();
                            $("#goods_quantity").focus();
                        }
                        var buttons = {
                            "save": {
                                text: "დამატება",
                                id: "add-goods",
                                click: function() {
                                }
                            }
                        };
                        /* Dialog Form Selector Name, Buttons Array */
                        GetDialog("add-edit-goods-form", 470, "auto", buttons);
                    }
                } else {	//IN
                    if (form == "add-edit-goods-form") {
                        //$("#object").attr("disabled", "disabled");
                    	var id = $("#overhead_id").val();
                        SeoY("goods_name", seoyURL, "overhead_goods_name", "", 0);
                        SeoY("goods_local_name", seoyURL, "overhead_goods_local_name", "id=" + id, 0);
                        var buttons = {
                            "save": {
                                text: "შენახვა",
                                id: "add-goods-identity",
                                click: function() {
                                }
                            }
                        };
                        /* Dialog Form Selector Name, Buttons Array */
                        GetDialog("add-edit-goods-form", 470, "auto", buttons);
                    } else {                    	
                        $("#o_type").attr("disabled", "disabled");
                        var buttons = {
                            "save": {
                                text: "არ ვეთანხმები",
                                id: "reject-overhead",
                                click: function() {
                                }
                            },
                            "active": {
                                text: "მივიღე",
                                id: "confirm-overhead",
                                click: function() {
                                }
                            }
                        };
                        var id = $("#overhead_id").val();
                        
                        $("#local_overhead_id").val(id);
                        $("#add_button_goods").css("display", "none");
                        $("#delete_button_goods").css("display", "none");
                        
                        LoadTable("goods_list");
                        GetButtons("", "", "export_button_goods");
                        
                        if (o_type == 1) {
                            /* Dialog Form Selector Name, Buttons Array */
                            GetDialog(fName, 950, "auto", buttons, "");
                        } else if(o_type == 2) {
                            /* Dialog Form Selector Name, Buttons Array */
                            GetDialog(fName, 950, "auto", buttons, "");
                        } else if (o_type == 3) {
                            /* Dialog Form Selector Name, Buttons Array */
                            GetDialog(fName, 950, "auto", buttons, "");
                        } else if (o_type == 6) {
                            /* Dialog Form Selector Name, Buttons Array */
                            GetDialog(fName, 950, "auto", buttons, "");
                            SeoY("buyer_name", seoyURL, "overhead_buyer_name", "", 0);
                        } else {
                            /* Dialog Form Selector Name, Buttons Array */
                            GetDialog(fName, 950, "auto", buttons, "");
                        }
                        
                        SeoY("driver_name", seoyURL, "overhead_driver_name", "", 0);
                        DisableRelations();
                        DisableTransport();
	                    
						var confirmed = $("#overhead_confirmed").val();
						var url = GetAjaxURL();
	                    
	                    if(confirmed == 0 || confirmed == 1){
	                    	GetDate("pay_needed_date");
	                        SetEvents("add_button_goods", "delete_button_goods", "check-all-goods", "goods_list", "add-edit-goods-form", url);
	                        
	                        $("#confirm-overhead").focus();
                    	}else if(confirmed == -1){
	                        SetEvents("add_button_goods", "delete_button_goods", "check-all-goods", "goods_list", "add-edit-goods-form", url);
                    		
                    		buttons = {
                                    "active": {
	                                text: "მივიღე",
	                                id: "confirm-overhead",
	                                click: function(){}
                            	}
                            };
                            
							$("#" + fName).dialog("option", "buttons", buttons);
							$("#confirm-overhead").focus();
                        }else if(confirmed == 2){
                        	//$("#object").attr("disabled", "disabled");  //Disable Object Selector
                        	DisableAccounts();
                        	
                    		buttons = {};
                    		
							$("#" + fName).dialog("option", "buttons", buttons);
							$("#export_button_goods").focus();
                        }
                    }
                }
            }
            
            //Active Overhead
            $(document).on("click", "#active-overhead", function() {
                overhead_id = SendOverhead();
                SetStatus(overhead_id, 1);
                if (overhead_id != 0) {
                    if (o_type != 6) {
                        var check = SendRS(overhead_id);
                        if (check) {
                            alert("ზედნადები წარმატებით გაიგზავნა rs.ge-ზე!!!");
                        } else {
                            SetStatus(overhead_id, 0);
                            alert("დაფიქსირდა შეცდომა: rs.ge-ზე ზედნადების გაგზავნა წარუმატებლად დასრულდა. გთხოვთ სცადოთ მოგვიანებით. თქვენი ზედნადები შეინახა!");
                        }
                    } else {
                        var check = SendRS(overhead_id);
                        if (check) {
                            var rs_id = GetRSID(overhead_id);
                            SetStatus(overhead_id, 2);

                            check = FinishOverheadRS(rs_id);
                            if (check) {
                                alert("ზედნადები წარმატებით დასრულდა rs.ge-ზე!!!");
                            } else {
                                SetStatus(overhead_id, 1);
                                alert("დაფიქსირდა შეცდომა: rs.ge-ზე ზედნადების დასრულდა წარუმატებლად დასრულდა. გთხოვთ სცადოთ მოგვიანებით!");
                            }
                        } else {
                            SetStatus(overhead_id, 0);
                            alert("დაფიქსირდა შეცდომა: rs.ge-ზე ზედნადების გაგზავნა წარუმატებლად დასრულდა. გთხოვთ სცადოთ მოგვიანებით. თქვენი ზედნადები შეინახა!");
                        }
                    }
                    var type = GetSelectedTab(tbName);

                    if (type == 0) {
                        LoadTable("out-overhead");
                    } else {
                        LoadTable("in-overhead");
                    }
                    CloseDialog(fName);
                }
            });

            //Active Saved Overhead
            $(document).on("click", "#active-saved-overhead", function() {
                overhead_id = $("#overhead_id").val();
                SetStatus(overhead_id, 1);

                var check = SendRS(overhead_id);
                if (check) {
                    alert("ზედნადები წარმატებით გაიგზავნა rs.ge-ზე!!!");
                } else {
                    SetStatus(overhead_id, 0);
                    alert("დაფიქსირდა შეცდომა: rs.ge-ზე ზედნადების გაგზავნა წარუმატებლად დასრულდა. გთხოვთ სცადოთ მოგვიანებით. თქვენი ზედნადები შეინახა!");
                }
                var type = GetSelectedTab(tbName);

                if (type == 0) {
                    LoadTable("out-overhead");
                } else {
                    LoadTable("in-overhead");
                }
                CloseDialog(fName);
            });

            //Finish Overhead
            $(document).on("click", "#finish-overhead", function() {
                var overhead_id = $("#overhead_id").val();
                var rs_id = GetRSID(overhead_id);
                SetStatus(overhead_id, 2);

                var check = FinishOverheadRS(rs_id);
                if (check) {
                    alert("ზედნადები წარმატებით დასრულდა rs.ge-ზე!!!");
                } else {
                    SetStatus(overhead_id, 1);
                    alert("დაფიქსირდა შეცდომა: rs.ge-ზე ზედნადების დასრულება წარუმატებლად დასრულდა. გთხოვთ სცადოთ მოგვიანებით!");
                }

                var type = GetSelectedTab(tbName);

                if (type == 0) {
                    LoadTable("out-overhead");
                } else {
                    LoadTable("in-overhead");
                }
                CloseDialog(fName);
            });

            //Save Overhead
            $(document).on("click", "#save-overhead", function() {
                overhead_id = SendOverhead();
                if (overhead_id != 0) {
                    SetStatus(overhead_id, 0);
                    alert("თქვენი ზედნადები შეინახა!");

                    var type = GetSelectedTab(tbName);

                    if (type == 0) {
                        LoadTable("out-overhead");
                    } else {
                        LoadTable("in-overhead");
                    }
                    CloseDialog(fName);
                }
            });

            //Load Sub Overhead
            $(document).on("click", "#sub_overhead_button", function() {
                $.ajax({
                    url: aJaxURL,
                    async: false, //r-value
                    data: "act=get_add_page&ot=" + 6, //Type sub_overhead
                    success: function(data) {
                        if (typeof (data.error) != "undefined") {
                            if (data.error != "") {
                                alert(data.error);
                            } else {
                                parent_id = $("#overhead_id").val();
                                CloseDialog(fName);
                                $("#" + fName).html(data.page);
                                LoadDialog("sub_overhead");
                            }
                        }
                    }
                });
            });

            //Main Overhead
            $(document).on("click", "#main-overhead", function() {
                if (confirm("დარწმუნებული ხართ?")) {
                    if (empty(parent_id)) {
                        var id = $("#overhead_id").val();
                        parent_id = GetParentID(id);
                    }
                    $.ajax({
                        url: aJaxURL,
                        data: "act=get_edit_page&id=" + parent_id,
                        success: function(data) {
                            if (typeof (data.error) != "undefined") {
                                if (data.error != "") {
                                    alert(data.error);
                                } else {
                                    CloseDialog("sub_overhead");
                                    $("#" + fName).html(data.page);
                                    LoadDialog(fName);
                                }
                            }
                        }
                    });
                }
            });

            //Confirm Overhead
            $(document).on("click", "#confirm-overhead", function() {
                var payed		= $("#payed").val();
                
                if (payed == "") {
                    alert("შეავსეთ გადახდილი თანხა!");
                } else {
                    var saller_id	= $("#seller_i_number").val();
                	var partner		= CheckPartner(saller_id);
                	
	                if (partner) {
	                    var id = $("#overhead_id").val();
		                var ident = CheckIdentity(id);                
		                if (ident) {
		                    var check = ConfirmOverheadRS(id);
		                    if (check) {                        
		                    	var object_id = $("#object").val();
		                    	var reserv = AddReserve(id, object_id);
		                    	if (reserv) {
		                            alert("პროდუქცია დაემატა მარაგში!");
		                            
                    				var type = GetSelectedTab(tbName);
		                            if (type == 0) {
		                            	LoadTable("out-overhead");
		                            } else {
		                            	LoadTable("in-overhead");
		                            }
		                            
		                        	AddPartnerAccount(type); //Partner account
		                        	
		                        	CloseDialog(fName);
		                    	}else{
		                    		alert("შეცდომა! პროდუქცია ვერ დამატდა საწყობში!");
			                    }
		                    } else {
		                        alert("დაფიქსირდა შეცდომა: rs.ge-ზე ზედნადების დადასტურება წარუმატებლად დასრულდა. გთხოვთ სცადოთ მოგვიანებით!");
		                    }
		                }
	                }
                }
            });
            
            //Reject Overhead
            $(document).on("click", "#reject-overhead", function() {
                var id = $("#overhead_id").val();

                var check = RejectOverheadRS(id);
                if(check){
                    var type = GetSelectedTab(tbName);

                    if (type == 0) {
                        LoadTable("out-overhead");
                    } else {
                        LoadTable("in-overhead");
                    }
                    CloseDialog(fName);
                }
            });

            // Add Goods
            $(document).on("click", "#add-goods", function() {
                param = new Object();

                //Action
                param.act	= "save_prod";
                param.obj	= $("#object").val();

                param.id	= $("#goods_id").val();
                param.li	= GetLocalID();

                //Main
                param.gc	= $("#goods_code").val().trim();
                param.gn	= $("#goods_name").val().trim();
                param.gm	= $("#goods_measure").val();
                param.gq	= $("#goods_quantity").val().trim();
                param.gu	= $("#goods_unit_price").val().trim();
                param.gp	= $("#goods_price").val().trim();
                param.gv	= $("#goods_vat").val();
                param.qf	= $("#goods_residual").val();                

                if (param.gc == "") {
                    alert("შეავსეთ საქონლის კოდი!");
                } else if (param.gn == "") {
                    alert("შეავსეთ საქონლის დასახელება!");
                } else if (param.gm == 0) {
                    alert("შეავსეთ საქონლის ზომის ერთეული!");
                } else if (param.gq == "" || param.gq <= 0) {
                    alert("შეავსეთ საქონლის რაოდენობა!");
                } else if (param.gu == "" || param.gu <= 0) {
                    alert("შეავსეთ საქონლის ერთეულის ფასი!");
                } else if (param.gp == "" || param.gp <= 0) {
                    alert("შეავსეთ საქონლის ფასი!");
                } else {
                    var url = GetAjaxURL();

                    $.ajax({
                        url: url,
                        data: param,
                        success: function(data) {
                            if (typeof(data.error) != "undefined") {
                                if (data.error != "") {
                                    alert(data.error);
                                } else {
                                    LoadTable("goods_list");
                                    CloseDialog("add-edit-goods-form");
                                }
                            }
                    	}
                	});
                }
            });

            // Add Goods Identity
            $(document).on("click", "#add-goods-identity", function() {
            	param = new Object();
            	
                //Action
                param.act	= "identity";
                
                //Main
                param.id		= $("#overhead_id").val();
                param.ovdetidl	= $("#overhead_detail_id_local").val();
                param.det_id	= $("#overhead_detail_id").val();   
                param.ident_id	= $("#identity_id").val();
                param.gn		= $("#goods_name").val();
                param.gln		= $("#goods_local_name").val();
                param.glq		= $("#goods_local_quantity").val().trim();
                param.glup		= $("#goods_local_unit_price").val();

                if (param.gln == "") {
                    alert("საქონლის დასახელება!");
                } else if (param.glq == "" || param.glq <= 0) {
                    alert("საქონლის რაოდენობა არასწორია!");
                } else if (param.glup == "" || param.glup <= 0) {
                    alert("საქონლის ერთეულის ფასი არასწორია!");
                } else {
                	var url = GetAjaxURL();
                    $.ajax({
                        url: url,
                        data: param,
                        success: function(data) {
                            if (typeof(data.error) != "undefined") {
                                if (data.error != "") {
                                    alert(data.error);
                                } else {
                                    LoadTable("goods_list");                        
                                    $("#add-edit-goods-form").dialog().dialog("destroy");
                                    CloseDialog("add-edit-goods-form");
                                }
                            }
                    	}
                    });
                }
            });

            //--Goods Out Calculations
            $(document).on("keydown", "#goods_code", function(event) {
                if (event.keyCode == $.ui.keyCode.ENTER) {
                    SetGoods(this.value, "");
                    event.preventDefault();					//Clear Dialog Default <b>keypress<b> Event
                }
            });

            $(document).on("keydown", "#goods_name", function(event) {
                if (event.keyCode == $.ui.keyCode.ENTER) {
                    SetGoods("", this.value);
                    event.preventDefault();					//Clear Dialog Default <b>keypress<b> Event
                }
            });

            $(document).on("keyup", "#goods_quantity", function(event) {
                var gq = $("#goods_quantity").val().trim();
                var gup = $("#goods_unit_price").val().trim();

                $("#goods_price").val((gq * gup).toFixed(4));
            });
            //--


            //--Goods In Calculations
            $(document).on("keyup", "#goods_local_quantity", function(event) {
                var gp	= $("#goods_price").val();
                var glq	= $("#goods_local_quantity").val().trim();
                
                $("#goods_local_unit_price").val((gp / glq).toFixed(4));
            });
            //--

            //Register Goods Enter Effect
            $(document).on("keypress", "#add-edit-goods-form", function(event) {
                var type = GetSelectedTab(tbName);
                if (event.keyCode == $.ui.keyCode.ENTER) {
                    if (type == 0) { //OUT
                        $("#add-goods").click();
                    } else { //IN
                        $("#add-goods-identity").click();
                    }
                }
            });
            //--

            //Driver Effects
            $(document).on("keydown", "#driver_id", function(event) {
                if (event.keyCode == $.ui.keyCode.ENTER) {
                    SetDriver(this.value, "");
                    $("#auto_number").focus();
                }
            });

            $(document).on("keydown", "#driver_name", function(event) {
                if (event.keyCode == $.ui.keyCode.ENTER) {
                    SetDriver("", this.value);
                    $("#auto_number").focus();
                }
            });
            //--

            //Buyer Effects
            $(document).on("keydown", "#buyer_i_number", function(event) {
                if (event.keyCode == $.ui.keyCode.ENTER) {
                    SetBuyer(this.value, "");
                }
            });

            $(document).on("keydown", "#buyer_name", function(event) {
                if (event.keyCode == $.ui.keyCode.ENTER) {
                    SetBuyer("", this.value);
                }
            });
            //--

            //--SeoY
            $(document).on("click", ".combobox", function(event) {
                var i = $(this).text();
                $("#" + i).autocomplete("search", "");
            });

            //--Overhead Type Change
            $(document).on("change", "#o_type", function(event) {
                o_type = this.value;

                $.ajax({
                    url: aJaxURL,
                    data: "act=get_add_page&ot=" + o_type,
                    success: function(data) {
                        if (typeof (data.error) != "undefined") {
                            if (data.error != "") {
                                alert(data.error);
                            } else {
                                CloseDialog(fName);
                                $("#" + fName).html(data.page);
                                LoadDialog(fName);
                            }
                        }
                    }
                });
            });

            function SendOverhead(status) {
                var overhead_id = 0;
                param = new Object();

                //Action
                param.act		= "save_overhead";

                param.id		= $("#overhead_id").val();
                param.obj		= $("#object").val();

                //Main
                param.ot		= o_type;
                param.on		= $("#o_number").val();
                param.ad		= $("#actation_data").val();
                param.pi		= parent_id;

                //Transport
                param.tt		= $("#transport_type").val();
                param.di		= $("#driver_id").val();
                param.dn		= $("#driver_name").val();
                param.an		= $("#auto_number").val();
                param.at		= $("#auto_trailer").val();
                param.aen		= $("#auto_expence_no").val();
                param.ae		= $("#auto_expence").val();

                //Buyer
                param.bin		= $("#buyer_i_number").val();
                param.bn		= $("#buyer_name").val();
                param.ba		= $("#buyer_addree").val();

                if (param.tt == "" && param.ot != 3 && param.ot != 6) {
                    alert("შეავსეთ ტრანსპორტირების სახე!");
                } else if (param.di == "" && param.ot != 3 && param.ot != 6) {
                    alert("შეავსეთ მძღოლის პ/ნ!");
                } else if (param.dn == "" && param.ot != 3 && param.ot != 6) {
                    alert("შეავსეთ მძღოლის სახელი და გვარი!");
                } else if (param.an == "" && param.ot != 3 && param.ot != 6) {
                    alert("შეავსეთ ა/მ ნომერი!");
                } else if (param.bin == "" && param.ot != 1 && param.ot != 4) {
                    alert("შეავსეთ მყიდველის საიდენტ. ნომერი!");
                } else if (param.bn == "" && param.ot != 1 && param.ot != 4) {
                    alert("შეავსეთ მყიდველის დასახელება / სახელი, გვარი!");
                } else if (param.ba == "" && param.ot != 1 && param.ot != 4) {
                    alert("შეავსეთ მყიდველის ტრანსპორტირების დაწყების ადგილი (მისამართი)!");
                } else {
                    $.ajax({
                        url: aJaxURL,
                        async: false, //r-value
                        data: param,
                        success: function(data) {
                            if (typeof(data.error) != "undefined") {
                                if (data.error != "") {
                                    alert(data.error);
                                } else {
                                    overhead_id = data.overhead_id;
                                    parent_id = 0;
                                }
                            }
                        }
                    });
                }

                return overhead_id;
            }
            
            function SendRS(overhead_id) {
                var check = false;
                $.ajax({
                    url: wsdlURL,
                    async: false, //r-value
                    data: "act=send_overhead&id=" + overhead_id,
                    success: function(data) {
                        if (typeof(data.error) != "undefined") {
                            if (data.error != "") {
                                alert(data.error);
                            } else {
                                check = true;
                            }
                        }
                    }
                });
                return check;
            }
            
            function FinishOverheadRS(rs_id) {
                var check = false;
                $.ajax({
                    url: wsdlURL,
                    async: false, //r-value
                    data: "act=finish_overhead&rs_id=" + rs_id,
                    success: function(data) {
                        if (typeof(data.error) != "undefined") {
                            if (data.error != "") {
                                alert(data.error);
                            } else {
                                check = true;
                            }
                        }
                    }
                });
                return check;
            }

            function ConfirmOverheadRS(overhead_id) {
                var check = false;
                var rs_id = GetRSID(overhead_id);
                $.ajax({
                    url: wsdlURL,
                    async: false, //r-value
                    data: "act=confirm_overhead&id=" + overhead_id + "&rs_id=" + rs_id,
                    success: function(data) {
                        if (typeof(data.error) != "undefined") {
                            if (data.error != "") {
                                alert(data.error);
                            } else {
                                check = true;
                            }
                        }
                    }
                });
                return check;
            }
            
            function RejectOverheadRS(overhead_id) {
                var check = false;
                $.ajax({
                    url: wsdlURL,
                    async: false, //r-value
                    data: "act=reject_overhead&id=" + overhead_id,
                    success: function(data) {
                        if (typeof(data.error) != "undefined") {
                            if (data.error != "") {
                                alert(data.error);
                            } else {
                                check = true;
                            }
                        }
                    }
                });
                return check;
            }

            function CheckIdentity(overhead_id) {
                var check = false;
                $.ajax({
                    url: aJaxURL,
                    async: false, //r-value
                    data: "act=check_identity&id=" + overhead_id,
                    success: function(data) {
                        if (typeof(data.error) != "undefined") {
                            if (data.error != "") {
                                alert(data.error);
                            } else {
                                check = true;
                            }
                        }
                    }
                });
                return check;
            }
            
            function CheckPartner(saller_id) {
                var check = false;
                $.ajax({
                    url: aJaxURL,
                    async: false, //r-value
                    data: "act=check_partner&id=" + saller_id,
                    success: function(data) {
                        if (typeof(data.error) != "undefined") {
                            if (data.error != "") {
                                alert(data.error);
                            } else {
                                check = true;
                            }
                        }
                    }
                });
                return check;
            }
            
            function AddReserve(overhead_id, object) {
                var check = false;
                $.ajax({
                    url: aJaxURL,
                    async: false, //r-value
                    data: "act=add_reserve&id=" + overhead_id + "&obj=" + object,
                    success: function(data) {
                        if (typeof(data.error) != "undefined") {
                            if (data.error != "") {
                                alert(data.error);
                            } else {
                                check = true;
                            }
                        }
                	}
            	});
                return check;
            }
            
            function AddPartnerAccount(type) {
            	param = new Object();
            	
                //Action
                param.act	= "add_partner_acc";
                
                param.id  	= $("#overhead_id").val();                
                param.bin	= $("#buyer_i_number").val();	//Partner ID
                param.pm	= $("#pay_method").val();
                param.pn	= $("#pay_nided").val();
                param.p		= $("#payed").val();
                param.pnd	= $("#pay_needed_date").val();
                param.type	= type;
                
                $.ajax({
                    url: aJaxURL,
                    data: param,
                    success: function(data) {
                        if (typeof(data.error) != "undefined") {
                            if (data.error != "") {
                                alert(data.error);
                            }
                        }
                	}
            	});
            }
            
            /**
             * Get next auto incremented id
             * @return {int}   Returns a next id
             */
            function GetLocalID() {
                var local_id;
                $.ajax({
                    url: aJaxURL,
                    async: false, //r-value
                    data: "act=get_local_id",
                    success: function(data) {
                        if (typeof(data.error) != "undefined") {
                            if (data.error != "") {
                                alert(data.error);
                            } else {
                                local_id = data.local_id;
                            }
                        }
                    }
                });
                return local_id;
            }
            
            /**
             * Set inputs Goods Name & Barcode
             * @param {int} barcode, {string} name,
             */
            function SetGoods(barcode, name) {
                var url = GetAjaxURL();
                $.ajax({
                    url: url,
                    data: "act=get_goods&bc=" + barcode + "&nm=" + name,
                    success: function(data) {
                        if (typeof(data.error) != "undefined") {
                            if (data.error != "") {
                                alert(data.error);
                            } else {
                                $("#goods_code").val(data.code);
                                $("#goods_name").val(data.name);
                                $("#goods_measure").val(data.measure);
                                $("#goods_unit_price").val(data.price);
                                $("#goods_quantity").val("");
                                $("#goods_quantity").focus();
                            }
                        }
                    }
                });
            }

            /**
             * Set inputs Buyer Name & Buyer Tin
             * @param {int} tin, {string} name,
             */
            function SetBuyer(tin, name) {
                var url = aJaxURL;
                $.ajax({
                    url: url,
                    data: "act=get_buyer&tn=" + tin + "&nm=" + name,
                    success: function(data) {
                        if (typeof(data.error) != "undefined") {
                            if (data.error != "") {
                                alert(data.error);
                            } else {
                                $("#buyer_i_number").val(data.tin);
                                $("#buyer_name").val(data.name);
                                $("#buyer_addree").val(data.address);
                            }
                        }
                    }
                });
            }

            /**
             * Set inputs Driver Name & Driver Tin
             * @param {int} tin, {string} name,
             */
            function SetDriver(tin, name) {
                var url = aJaxURL;
                $.ajax({
                    url: url,
                    data: "act=get_driver&tn=" + tin + "&nm=" + name,
                    success: function(data) {
                        if (typeof(data.error) != "undefined") {
                            if (data.error != "") {
                                alert(data.error);
                            } else {
                                $("#driver_id").val(data.tin);
                                $("#driver_name").val(data.name);
                                $("#auto_expence_no").val(0);
                            }
                        }
                    }
                });
            }
            
            function SetCurrentObject(overhead_id) {
                $.ajax({
                    url: aJaxURL,
                    data: "act=get_current_object&id=" + overhead_id,
                    success: function(data) {
                        if (typeof(data.error) != "undefined") {
                            if (data.error != "") {
                                alert(data.error);
                            } else {
                                $("#object").val(data.object_id);
                            }
                        }
                    }
                });
            }
            
            /**
             * Get serverside URL
             * @return {String}   Returns a string value url
             */
            function GetAjaxURL() {
                var url;
                var type = GetSelectedTab(tbName);

                switch (type) {  
                    case 0:
                        url = "server-side/documents/overhead/in.action.php";
                        break;
                    case 1:
                        url = "server-side/documents/overhead/in.action.php";
                        break;
                    case 3:
                        url = "server-side/documents/overhead/out.action.php";
                        break;
                    case 2:
                        url = "server-side/documents/overhead/out.action.php";
                        break;
                    default:
                        url = null;
                }
                return url;
            }

            function GetParentID(overhead_id) {
                var local_par_id;
                $.ajax({
                    url: aJaxURL,
                    async: false, //r-value
                    data: "act=get_parent_id&id=" + overhead_id,
                    success: function(data) {
                        if (typeof(data.error) != "undefined") {
                            if (data.error != "") {
                                alert(data.error);
                            } else {
                                local_par_id = data.local_par_id;
                            }
                        }
                    }
                });
                return local_par_id;
            }

            function GetRSID(overhead_id) {
                var rs_id;
                $.ajax({
                    url: aJaxURL,
                    async: false, //r-value
                    data: "act=get_rs_id&id=" + overhead_id,
                    success: function(data) {
                        if (typeof(data.error) != "undefined") {
                            if (data.error != "") {
                                alert(data.error);
                            } else {
                                rs_id = data.rs_id;
                            }
                        }
                    }
                });
                return rs_id;
            }

            function AddSubGoods(overhead_id, local_par_id) {
                var url = GetAjaxURL();
                $.ajax({
                    url: url,
                    data: "act=add_sub_goods&o_id=" + overhead_id + "&parent_id=" + local_par_id,
                    success: function(data) {
                        if (typeof(data.error) != "undefined") {
                            if (data.error != "") {
                                alert(data.error);
                            }else{
                            	LoadTable("goods_list");                                
                                SetEvents("", "", "", "goods_list", "add-edit-goods-form", url, "ot=" + o_type);
                            }
                        }
                    }
                });
            }

            function SetStatus(overhead_id, status) {
                $.ajax({
                    url: aJaxURL,
                    data: "act=set_status&o_id=" + overhead_id + "&os=" + status,
                    success: function(data) {
                        if (typeof(data.error) != "undefined") {
                            if (data.error != "") {
                                alert(data.error);
                            }
                        }
                    }
                });
            }
            
            function ClearDB() {
                $.ajax({
                    url: aJaxURL,
                    data: "act=clear_db",
                    success: function(data) {
                        if (typeof(data.error) != "undefined") {
                            if (data.error != "") {
                                alert(data.error);
                            }
                        }
                    }
                });
            }
            
            function DisableHeader() {
                $("#o_type").attr("disabled", "disabled");
                //$("#object").attr("disabled", "disabled");
            }
            
            function DisableTransport() {
                $("#transport_type").attr("disabled", "disabled");
                $("#driver_id").attr("disabled", "disabled");
                $("#driver_name").attr("disabled", "disabled");
                $("#auto_number").attr("disabled", "disabled");
                $("#auto_trailer").attr("disabled", "disabled");
                $("#auto_expence_no").attr("disabled", "disabled");
                $("#auto_expence").attr("disabled", "disabled");
                $("#driver_name_btn").button("disable");
            }
            
            function DisableRelations() {
                $("#buyer_i_number").attr("disabled", "disabled");
                $("#buyer_name").attr("disabled", "disabled");
                $("#buyer_name_btn").button("disable");
                $("#buyer_addree").attr("disabled", "disabled");
            }
            
            function DisableGoods() {
                $("#add_button_goods").button("disable");
                $("#delete_button_goods").button("disable");
            }
            
            function DisableGoodsList() {
                $("#goods_code").attr("disabled", "disabled");
                $("#goods_name").attr("disabled", "disabled");
                $("#goods_name_btn").button("disable");
                $("#goods_vat").attr("disabled", "disabled");
            }
            
            function DisableAccounts() {
                $("#pay_method").attr("disabled", "disabled");
                $("#pay_nided").attr("disabled", "disabled");
                $("#payed").attr("disabled", "disabled");
                $("#pay_needed_date").attr("disabled", "disabled");
            }

           $(document).on("keypress", "#goods_local_name", function(e) {
                var name = $("#goods_local_name").val();
                if(e.which == 13){
	             	$.ajax({
	                    url: "server-side/documents/overhead/in.action.php",
	                    data: "act=get_unit&name=" + name,
	                    success: function(data) {
	                        if (typeof(data.error) != "undefined") {
	                            if (data.error != "") {
	                                alert(data.error);
	                            }else{
									$("#goods_local_unit").val(data.unit);
									if($("#goods_local_unit").val() != $("#goods_measure option:selected").text()){
										alert("მომწოდებლის ზომის ერთეული არ ემთხვევა თქვენსას!\nმიღებული საქონლის რაოდენობა შეიყვანეთ თქვენი ერთეულის მიხედვით!");
									}
	                        	}
	                        }
	                    }
	                });             
                }
            });

      		$(document).on("keyup", "#goods_local_quantity", function() {
    		    var val = $(this).val();
    		    if(isNaN(val)){
    			     alert("შეიყვანეთ მხოლოდ ციფრები");
    		         val = val.replace(/[^0-9\.]/g,'');
    		         if(val.split('.').length>2) 
    		             val =val.replace(/\.+$/,"");
    		    }
    		    $(this).val(val); 
    		});
        </script>
</head>
<body>
	<div id="tabs" style="width: 1024px; margin: 0 auto; margin-top:15px; min-height: 768px;">
		<ul>
			<li><a href="#tab-in">მისაღები</a></li>
			<li><a href="#tab-in1">მიღებული</a></li>
			<li><a href="#tab-out">გასაცემი</a></li>
			<li><a href="#tab-out1">გაცემული</a></li>	
		</ul>
		<div id="tab-out">
			<div id="dt_example" class="ex_highlight_row">
				<div id="container" class="overhead_container">
					<div id="dynamic">
						<h2>გაცემა ზედნადებით</h2>
						<div id="button_area">
							<button id="add_button_out">ახალი ზედნადები</button>
							<button id="cancel_button_out">გაუქმება</button>
							<button id="delete_button_out">წაშლა</button>
						</div>
						<table class="display" id="out-overhead">
							<thead>
								<tr id="datatable_header">
									<th>ID</th>
									<th class="min">ზედნადები</th>
									<th class="min">ტიპი</th>
									<th style="width: 315px">პარტნიორი</th>
									<th class="min">თანხა</th>
									<th class="min">გააქტიურების თარ.</th>
									<th class="check">#</th>
								</tr>
							</thead>
							<thead>
								<tr class="search_header">
									<th class="colum_hidden">
										<input type="text" name="search_id" value="ფილტრი" class="search_init" />
									</th>
									<th>
										<input type="text" name="search_overhead" value="ფილტრი" class="search_init" />
									</th>
									<th>
										<input type="text" name="search_partner" value="ფილტრი" class="search_init" />
									</th>
									<th>
										<input type="text" name="search_doc_date" value="ფილტრი" class="search_init" />
									</th>
									<th>
										<input type="text" name="search_op_date" value="ფილტრი" class="search_init" />
									</th>
									<th>
										<input type="text" name="search_sum_cost" value="ფილტრი" class="search_init" />
									</th>
									<th>
										<input type="checkbox" name="check-all" id="check-all-out">
									</th>
								</tr>
							</thead>
						</table>
					</div>
					<div class="spacer"></div>
				</div>
			</div>
		</div>
		<div id="tab-out1">
			<div id="dt_example" class="ex_highlight_row">
				<div id="container" class="overhead_container">
					<div id="dynamic">
						<h2>გაცემა ზედნადებით</h2>
						<div id="button_area">
							<button id="add_button_out1">ახალი ზედნადები</button>
							<button id="cancel_button_out1">გაუქმება</button>
							<button id="delete_button_out1">წაშლა</button>
						</div>
						<table class="display" id="out-overhead1">
							<thead>
								<tr id="datatable_header">
									<th>ID</th>
									<th class="min">ზედნადები</th>
									<th class="min">ტიპი</th>
									<th style="width: 315px">პარტნიორი</th>
									<th class="min">თანხა</th>
									<th class="min">გააქტიურების თარ.</th>
									<th class="check">#</th>
								</tr>
							</thead>
							<thead>
								<tr class="search_header">
									<th class="colum_hidden">
										<input type="text" name="search_id" value="ფილტრი" class="search_init" />
									</th>
									<th>
										<input type="text" name="search_overhead" value="ფილტრი" class="search_init" />
									</th>
									<th>
										<input type="text" name="search_partner" value="ფილტრი" class="search_init" />
									</th>
									<th>
										<input type="text" name="search_doc_date" value="ფილტრი" class="search_init" />
									</th>
									<th>
										<input type="text" name="search_op_date" value="ფილტრი" class="search_init" />
									</th>
									<th>
										<input type="text" name="search_sum_cost" value="ფილტრი" class="search_init" />
									</th>
									<th>
										<input type="checkbox" name="check-all" id="check-all-out">
									</th>
								</tr>
							</thead>
						</table>
					</div>
					<div class="spacer"></div>
				</div>
			</div>
		</div>
		<div id="tab-in">
			<div id="dt_example" class="ex_highlight_row">
				<div id="container" class="overhead_container">
					<div id="dynamic">
						<h2>მიღება ზედნადებით</h2>
						<div id="button_area">
							<button id="add_button_in">ახალი ზედნადები</button>
							<button id="cancel_button_in">გაუქმება</button>
							<button id="delete_button_in">წაშლა</button>
						</div>
						<table class="display" id="in-overhead">
							<thead>
								<tr id="datatable_header">
									<th>ID</th>
									<th class="min">ზედნადები</th>
									<th class="min">ტიპი</th>
									<th style="width: 315px">პარტნიორი</th>
									<th class="min">თანხა</th>
									<th class="min">გააქტიურების თარ.</th>
									<th class="check">#</th>
								</tr>
							</thead>
							<thead>
								<tr class="search_header">
									<th class="colum_hidden">
										<input type="text" name="search_id" id="search_id" value="ფილტრი" class="search_init" /></th>
									<th>
										<input type="text" name="search_overhead" value="ფილტრი" class="search_init" /></th>
									<th>
										<input type="text" name="search_partner" value="ფილტრი" class="search_init" /></th>
									<th>
										<input type="text" name="search_doc_date" value="ფილტრი" class="search_init" /></th>
									<th>
										<input type="text" name="search_op_date" value="ფილტრი" class="search_init" /></th>
									<th>
										<input type="text" name="search_sum_cost" value="ფილტრი" class="search_init" /></th>
									<th>
										<input type="checkbox" name="check-all" id="check-all-in">
									</th>
								</tr>
							</thead>
						</table>
					</div>
					<div class="spacer"></div>
				</div>
			</div>
		</div>
	
	<div id="tab-in1">
			<div id="dt_example" class="ex_highlight_row">
				<div id="container" class="overhead_container">
					<div id="dynamic">
						<h2>მიღება ზედნადებით</h2>
						<div id="button_area">
							<button id="add_button_in1">ახალი ზედნადები</button>
							<button id="cancel_button_in1">გაუქმება</button>
							<button id="delete_button_in1">წაშლა</button>
						</div>
						<table class="display" id="in-overhead1">
							<thead>
								<tr id="datatable_header">
									<th>ID</th>
									<th class="min">ზედნადები</th>
									<th class="min">ტიპი</th>
									<th style="width: 315px">პარტნიორი</th>
									<th class="min">თანხა</th>
									<th class="min">გააქტიურების თარ.</th>
									<th class="check">#</th>
								</tr>
							</thead>
							<thead>
								<tr class="search_header">
									<th class="colum_hidden">
										<input type="text" name="search_id" id="search_id" value="ფილტრი" class="search_init" /></th>
									<th>
										<input type="text" name="search_overhead" value="ფილტრი" class="search_init" /></th>
									<th>
										<input type="text" name="search_partner" value="ფილტრი" class="search_init" /></th>
									<th>
										<input type="text" name="search_doc_date" value="ფილტრი" class="search_init" /></th>
									<th>
										<input type="text" name="search_op_date" value="ფილტრი" class="search_init" /></th>
									<th>
										<input type="text" name="search_sum_cost" value="ფილტრი" class="search_init" /></th>
									<th>
										<input type="checkbox" name="check-all" id="check-all-in">
									</th>
								</tr>
							</thead>
						</table>
					</div>
					<div class="spacer"></div>
				</div>
			</div>
		</div>
	

	<!-- jQuery Dialog -->
	<div id="add-edit-form" class="form-dialog" title="ზედნადები">
		<!-- aJax -->
	</div>
</body>
</html>